package com.ncp.servlet.bbs;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.ncp.model.biz.bbs.ArticleProcess;


public class ArticleProcessServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html");
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		
		HttpSession session=request.getSession();
		String name=(String)session.getAttribute("LoginName");
		if(name==null){
			response.sendRedirect("index.jsp");
			return;
		}
		String title=request.getParameter("title");
		String cont=request.getParameter("cont");
	//	System.out.println(title);
		ArticleProcess ap=new ArticleProcess();
		if(ap.Postsubject(0, title, cont, name)){
			response.sendRedirect("pages/bbs/showarticle.jsp");
		}
	}


	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			
		this.doGet(request, response);
	}

}
